﻿using Client.Framework.Message;
using Client.Framework.Socket;
using Client.Service;
using Client.ViewModel;
using System;
using System.Windows;

namespace Client
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow(LoginWindow loginWindow)
        {
            //InitSocketClient();

            //InitSysData();
            LoginWindow = loginWindow;
            InitializeComponent();
            MainWindowViewModel viewModel = new MainWindowViewModel(this)
            {
                CurrentLoginUser = ApplicationClient.Instance().CurrentLoginUser
            };
            DataContext = viewModel;

        }


        public LoginWindow LoginWindow { get; set; }



        /// <summary>
        /// 启动Socket客户端
        /// </summary>
        private void InitSocketClient()
        {
            MessageTypeManager.Init();
            ApplicationClient.Instance().InitClient();
        }

        /// <summary>
        /// 初始化系统数据
        /// </summary>
        private void InitSysData()
        {
            RoleService.Instance().InitRoles();
            OrgService.Instance().InitOrgTree();
        }



        protected override void OnClosed(EventArgs e)
        {
            Application.Current.Shutdown();
            base.OnClosed(e);
        }





    }
}
